import { defineStore } from 'pinia'
import { hireAll, resumeAll } from '../../api/hire'

// 用户模块 token setToken removeToken
export const useHireStore = defineStore(
  'hire',
  {
    state: () => ({
      //所有招聘信息
      jobsData: {
        recruit: [],
        total: 3
      },
      //所有简历信息
      resumeData: {
        resume: [],
        total: 3
      }
      //所有员工信息--用于分页
      //   allEmployees: [],
      //   //模糊查询需要的数据
      //   search: {
      //     department: '',
      //     name: ''
      //   },
    }),
    actions: {
      //获取招聘所有信息
      async fetchJobAll() {
        const res = await hireAll()
        Object.assign(this.jobsData, res.data)
        // console.log(this.jobsData, '招聘')
      },
      //获取简历所有信息
      async fetchResumeAll() {
        const res = await resumeAll()
        Object.assign(this.resumeData, res.data)
        // console.log(res, '简历res')
      }
    }
  },
  {
    persist: true
  }
)
